<template>
  <div class="body">
    <van-cell-group>
      <van-cell title="注销" icon="close" @click="cog"/>
    </van-cell-group>
  </div>
</template>

<script>
  import router from '@/router/index'
  import { Cell, CellGroup, Icon, Dialog } from 'vant';

  export default {
    name: "PersonalCog",
    components:{
      [Cell.name]: Cell,
      [CellGroup.name]: CellGroup,
      [Icon.name]: Icon,
      [Dialog.name]: Dialog,
    },
    methods: {
      cog: function () {
        Dialog.confirm({
          title: '您确定要注销吗？',
        }).then(() => {
          let _this = this;
          let token = _this.getCookie("token");
          _this.$http.get(_this.apiUrl("user/users/logout"), {headers: {'token': token}})
            .then((res) => {
              console.log(res.data);
              _this.clearCookie("token");
              _this.clearCookie("expire_time");
              router.push({
                path: '/Login'
              })
            });
        }).catch(() => {
        });
      }
    }
  }
</script>

<style scoped>

</style>
